The resource name of the font you prefer.

You can easily obtain this name using the GdPicturePDF.AddStandardFont method or any of the AddTrueTypeFont...() methods. For further assistance, please see the section Fonts of the GdPicturePDF class in the Reference Guide.

The size of the text (the font size actually), in points.
Set this parameter to true if you want to determine the font height by using the font boundary box. It is an imaginary box that encloses all glyphs from the font, usually as tightly as possible. It is represented by four parameters.

Set this parameter to false if you want to determine the font height by using the font's ascent and descent properties. The ascent property is the distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.

Example





In This Topic
GdPicture.NET.14 (COM - ActiveX)~GdPicture14_namespace / GdPicture.NET.14 (COM - ActiveX)~GdPicture14.GdPicturePDF / GetTextHeight_2 Method

GetTextHeight_2 Method (GdPicturePDF)

In This Topic
Calculates the height of the font you have specified, expressed in the current units used in the loaded PDF document.

You can use the GdPicturePDF.GetMeasurementUnit method to determine the currently defined units and you can also use the GdPicturePDF.SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration
 
Public Function GetTextHeight_2( _
   ByVal FontResName As String, _
   ByVal TextSize As Single, _
   ByVal UseFontBox As Boolean _
) As Single
public float GetTextHeight_2( 
   string FontResName,
   float TextSize,
   bool UseFontBox
)
public function GetTextHeight_2( 
    FontResName: String;
    TextSize: Single;
    UseFontBox: Boolean
): Single; 
public function GetTextHeight_2( 
   FontResName : String,
   TextSize : float,
   UseFontBox : boolean
) : float;
public: float GetTextHeight_2( 
   string* FontResName,
   float TextSize,
   bool UseFontBox
) 
public:
float GetTextHeight_2( 
   String^ FontResName,
   float TextSize,
   bool UseFontBox
) 

Parameters

FontResName
The resource name of the font you prefer.

You can easily obtain this name using the GdPicturePDF.AddStandardFont method or any of the AddTrueTypeFont...() methods. For further assistance, please see the section Fonts of the GdPicturePDF class in the Reference Guide.

TextSize
The size of the text (the font size actually), in points.
UseFontBox
Set this parameter to true if you want to determine the font height by using the font boundary box. It is an imaginary box that encloses all glyphs from the font, usually as tightly as possible. It is represented by four parameters.

Set this parameter to false if you want to determine the font height by using the font's ascent and descent properties. The ascent property is the distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.

Return Value

The height of the specified font, expressed in the current units specified by the SetMeasurementUnit method.

The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.

Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any. For example, if the currently loaded PDF document does not contain any page, this method will fail.

Just to remind you that 1 point is equivalent to 1/72 of an inch.

Example
How to determine the height of the standard Times-Roman font with and without respect to the font boundary box.
Dim caption As String = "Example: GetTextHeight_2"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman)
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            Dim message As String = ""
            Dim height As Single = gdpicturePDF.GetTextHeight_2(fontName, 20, True)
            status = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                message = message + "The height of the Times-Roman font with the size 20, with respect to the font boundary box, is " + height.ToString() + " centimeters."
            Else
                message = message + "The GetTextHeight_2() method has failed with the status: " + status.ToString()
            End If
            
            height = gdpicturePDF.GetTextHeight_2(fontName, 20, False)
            status = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                message = message + vbCrLf + "The height of the Times-Roman font with the size 20, without respecting the font boundary box, is " + height.ToString() + " centimeters."
            Else
                message = message + vbCrLf + "The GetTextHeight_2() method has failed with the status: " + status.ToString()
            End If
            MessageBox.Show(message, caption)
        Else
            MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
        End If
    Else
        MessageBox.Show("Units can't be set correctly.", caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetTextHeight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman);
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            string message = "";
            float height = gdpicturePDF.GetTextHeight(fontName, 20, true);
            status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
                message = message + "The height of the Times-Roman font with the size 20, with respect to the font boundary box, is " + height.ToString() + " centimeters.";
            else
                message = message + "The GetTextHeight() method has failed with the status: " + status.ToString();
            
            height = gdpicturePDF.GetTextHeight(fontName, 20, false);
            status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
                message = message + "\nThe height of the Times-Roman font with the size 20, without respecting the font boundary box, is " + height.ToString() + " centimeters.";
            else
                message = message + "\nThe GetTextHeight() method has failed with the status: " + status.ToString();
            MessageBox.Show(message, caption);
        }
        else
            MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
    }
    else
        MessageBox.Show("Units can't be set correctly.", caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also